$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_kjkhgl_m")
    const dgrid1 = $NG.getCmpApi("p_form_kjkhgl_d1")
    const dgrid2 = $NG.getCmpApi("p_form_kjkhgl_d2")
    const dgrid3 = $NG.getCmpApi("p_form_kjkhgl_d3")

    const getHeadValue = (str) => mstform.getItem(str).getValue()

    useAction("clickHighlight")(function (...e) {
        console.log(`e`, e);
    }, 'p_form_kjkhgl_d1.u_zp')
    if (page.oType == 'add') {
        mstform.getItem("u_tbnd").setValue({
            label:new Date().getFullYear(),
            value:new Date().getFullYear(),
        })
        mstform.getItem("u_sm").setValue(`请上传Word格式。包括1.考核自评价报告；2.考核佐证材料；3.本年度科技工作总结及下年度工作计划。`)
        getKjkhglInfo()
        getKjkhglInfoTowOrg()
        getKjkhglInfoTowJy()
    }

    useValuesChange(() => {
        console.log(`得分变化`,);
        if ((Number(mstform.getItem("u_jyyjkhkjcxzbdf").getValue()) || 0) > 5) {
            $NG.updateState(updater => {
                updater.data.p_form_kjkhgl_m.setProps({
                    u_jyyjkhkjcxzbdf: 5
                })
            })
        }
    }, "p_form_kjkhgl_m.u_jyyjkhkjcxzbdf")

    // 获取明细数据
    function getKjkhglInfo() {
        $NG.execServer("getKjkhglInfo", {}, (res) => {
            if (res.count == 0) return
            const datas = JSON.parse(res.data).reduce((value, item) => {
                item.extendObjects.u_zp = 0
                item.extendObjects.u_gskp = 0
                value.push(item.extendObjects)
                return value
            }, [])
            dgrid1.addRows(datas)
        })
    }

    function getKjkhglInfoTowOrg() {
        $NG.execServer("getKjkhglInfoTowOrg", {}, (res) => {
            if (res.count == 0) return
            const datas = JSON.parse(res.data).reduce((value, item) => {
                item.extendObjects.u_zp = 0
                item.extendObjects.u_gskp = 0
                value.push(item.extendObjects)
                return value
            }, [])
            dgrid2.addRows(datas)
        })
    }

    function getKjkhglInfoTowJy() {
        $NG.execServer("getKjkhglInfoTowJy", {}, (res) => {
            if (res.count == 0) return
            const datas = JSON.parse(res.data).reduce((value, item) => {
                item.extendObjects.u_zp = 0
                item.extendObjects.u_gskp = 0
                value.push(item.extendObjects)
                return value
            }, [])
            dgrid3.addRows(datas)
        })
    }

}, function () {
    return {
        /**
         * @param defaultParams:IObject 默认请求参数
         * @return IObject
         */
        transferListReqParams(defaultParams) {
            console.log(`defaultParams`, defaultParams);
            //   return {
            //     ...defaultParams,
            //     userParam: 'test'
            //   };
        }
    };
})